﻿package com.wandian.util
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	/**   
	* @author long
	* @QQ 108232706
	* @version 1.0   
	*/   
	public class CLZButtonFour extends Object
	{
		private var mcButton:MovieClip;
		public static const UP_NO:uint=1;
		public static const OVER_NO:uint=2;
		public static const UP_YES:uint=3;
		public static const OVER_YES:uint=4;

		public function CLZButtonFour()
		{
			return;
		} 

		public static function initBtn(mcBtn:MovieClip, boolSelect:Boolean=false):void
		{
			mcBtn.isSelected=boolSelect;
			if (mcBtn.isSelected)
			{
				mcBtn.gotoAndStop(UP_YES);
			}
			else
			{
				mcBtn.gotoAndStop(UP_NO);
			}
			return;
		} 

		public static function setBtnSelect(mcBtn:MovieClip, boolSelect:Boolean=false):void
		{
			mcBtn.isSelected=boolSelect;
			return;
		} 

		public static function setButton(mcBtn:MovieClip, txtMsg:String="", isSelected:Boolean=false, strColor:String="", noSelected:Boolean=true):void
		{
			var overHandler:Function;
			var outHandler:Function;
			var downHandler:Function;
			var upHandler:Function;
			var mcButton:*=mcBtn;
			var updateTxtAndColor:*=function(param1:MovieClip, param2:int=0):void
			{
				if (param1.txtMsg != "")
				{
				}
				if (param1.txt != null)
				{
					param1.txt.text=param1.txtMsg;
					if (param1.arrColor != [])
					{
						param1.txt.textColor=param1.arrColor[param2];
					}
				}
				return;
			} 
			;
			var removeButton:*=function(param1:MovieClip):void
			{
				param1.removeEventListener(MouseEvent.MOUSE_OVER, overHandler);
				param1.removeEventListener(MouseEvent.MOUSE_OUT, outHandler);
				param1.removeEventListener(MouseEvent.MOUSE_DOWN, downHandler);
				param1.removeEventListener(MouseEvent.MOUSE_UP, upHandler);
				return;
			} 
			;
			overHandler=function(event:MouseEvent):void
			{
				var _loc_2:*=event.currentTarget as MovieClip;
				if (_loc_2.isSelected)
				{
					_loc_2.gotoAndStop(OVER_YES);
					updateTxtAndColor(_loc_2, (OVER_YES - 1));
				}
				else
				{
					_loc_2.gotoAndStop(OVER_NO);
					updateTxtAndColor(_loc_2, (OVER_NO - 1));
				}
				return;
			} 
			;
			outHandler=function(event:MouseEvent):void
			{
				var _loc_2:*=event.currentTarget as MovieClip;
				if (_loc_2.isSelected)
				{
					_loc_2.gotoAndStop(UP_YES);
					updateTxtAndColor(_loc_2, (UP_YES - 1));
				}
				else
				{
					_loc_2.gotoAndStop(UP_NO);
					updateTxtAndColor(_loc_2, (UP_NO - 1));
				}
				return;
			} 
			;
			downHandler=function(event:MouseEvent):void
			{
				var _loc_2:*=event.currentTarget as MovieClip;
				if (!noSelected)
				{
					_loc_2.isSelected=false;
				}
				if (_loc_2.isSelected)
				{
					_loc_2.isSelected=false;
					_loc_2.gotoAndStop(UP_NO);
					updateTxtAndColor(_loc_2, (UP_NO - 1));
				}
				else
				{
					_loc_2.isSelected=true;
					_loc_2.gotoAndStop(UP_YES);
					updateTxtAndColor(_loc_2, (UP_YES - 1));
				}
				_loc_2.dispatchEvent(new Event(Event.CHANGE));
				return;
			} 
			;
			upHandler=function(event:MouseEvent):void
			{
				var _loc_2:*=event.currentTarget as MovieClip;
				if (_loc_2.isSelected)
				{
					_loc_2.gotoAndStop(OVER_YES);
					updateTxtAndColor(_loc_2, (OVER_YES - 1));
				}
				else
				{
					_loc_2.gotoAndStop(OVER_NO);
					updateTxtAndColor(_loc_2, (OVER_NO - 1));
				}
				return;
			} 
			;
			mcButton.mouseChildren=false;
			mcButton.buttonMode=true;
			var arrColor:*=strColor.split(",");
			mcButton.arrColor=arrColor;
			mcButton.txtMsg=txtMsg;
			mcButton.isSelected=isSelected;
			if (mcButton.isSelected)
			{
				mcButton.gotoAndStop(UP_YES);
			}
			else
			{
				mcButton.gotoAndStop(UP_NO);
			}
			updateTxtAndColor(mcButton);
			mcButton.addEventListener(MouseEvent.MOUSE_OVER, overHandler);
			mcButton.addEventListener(MouseEvent.MOUSE_OUT, outHandler);
			mcButton.addEventListener(MouseEvent.MOUSE_DOWN, downHandler);
			mcButton.addEventListener(MouseEvent.MOUSE_UP, upHandler);
			return;
		} 

	}
}
